#ifndef CONFIGURATOR_H
#define CONFIGURATOR_H
#include <map>
#include <string>
#include <algorithm>
/*
class config_param
{
	template<typename T>
	virtual bool get(T& dest)
	{
		return false;
	}
	template<typename T>
	virtual bool set(T& dest)
	{ // ~~ different type is associated with this key 
		return false;
	}
};

template<typename T>
class config_param_t
{
public:
	config_param_t(){}
	config_param_t(T& src): val(src){}
	virtual bool get(T& dest)
	{
		dest = val;
		return true;
	}
	virtual bool set(T& src)
	{
		val = src;
		return true;
	}
protected:
	T val;
};

class configurator
{
protected:
	typedef std::map<std::string, config_param*> cmap;
	typedef std::pair<std::string, config_param*> cpair;

public:	
	configurator(){}
	virtual ~configurator()
	{
		std::for_each(vals.begin(), vals.end(), delmem);
	}
	template<typename T>
	bool get(const std::string& key, T& val)
	{
		cmap::iterator i = vals.find(key);
		return (i == vals.end())?
					false : i->second()->get(val);
	}
	template<typename T>
	void set(const std::string& key, T& val)
	{
		cmap::iterator i = vals.find(key);
		if(i == vals.end() )
		{
			vals.insert( create_entry(key, val) );
			return true;
		}
		else
			return i->second()->set(val);
	}

protected:
	configurator(const configurator&); //there are pointers here ffs
	static void delmem(cpair& p)
	{
		delete p.second();
	}
	template<typename T> cpair create_entry(string key, T& val)
	{
		return cpair(key, (config_param*)new config_param_t<T>(val));
	}
	std::map<std::string, config_param*> vals;
};
*/
#endif